Conversation
…-filters-to-be-routable
Had to remove these becuase they were causing double navigations on each click.
vault-filter.component was pushing up old filter models which would sometimes overwrite new filter models that came from the routed filter service.
|
|
||
| if (filter.type !== undefined && filter.type === "trash") { | ||
| legacyFilter.selectedCipherTypeNode = { | ||
| node: { id: "trash", name: "", icon: "", type: "trash" }, |
There was a problem hiding this comment.
minor suggestion: you could use the TreeNode constructor here:
legacyFilter.selectedCipherTypeNode = new TreeNode<CipherTypeFilter>({ id: "trash", name: "", type: "trash", icon: ""}, null);we really should refactor this constructor to be more useful, I don't even think this will save you that many characters 😄
There was a problem hiding this comment.
My question was going to be whether we could find the existing Trash node, or export & import the Trash node object, rather than recreating it. It looks like it's currently declared in the VaultFilterComponent though, which I guess we don't really want to pull in to a service.
In any case I agree you should use a real TreeNode object, not really to save any characters, just to be properly typesafe.
There was a problem hiding this comment.
lgtm but I'll let @jlf0dev resolve the thread when he's happy
|
|
||
| const bridgeModel = new RoutedVaultFilterBridge(filter, legacyFilter, this); | ||
|
|
||
| return bridgeModel; |
There was a problem hiding this comment.
suggestion: unnecessary variable here, just return the model
There was a problem hiding this comment.
Huh, I wonder why I did this. Must've been a console.log here at some point 😅
| import { RoutedVaultFilterService } from "./routed-vault-filter.service"; | ||
|
|
||
| @Injectable() | ||
| export class RoutedVaultFilterBridgeService { |
There was a problem hiding this comment.
suggestion: you could add a jsdoc comment here explaining the purpose of the bridge service
There was a problem hiding this comment.
Something I'm wondering about 😁 is it transitional? If so, do we need a tech debt ticket to remove the old services? I assume that when we build the new filter list in the left-hand nav, they'll be routing directly to the query URL rather than going via a service, and then it'll be much simpler to clean up the old code. This feels like something EC pod should do as part of VVR, before handing off to Vault team.
Note that we also have DeprecatedVaultFilterService floating around 🤯
EDIT: ok, after reviewing the rest of the code, (I think) I understand that this is basically a wrapper around existing logic to implement routing with a minimum of code changes. The downside is that it adds complexity in the short term, but I'm OK with this if we're deprecating it quickly after VVR (because the new components won't use it).
There was a problem hiding this comment.
@jlf0dev Sure I can add the file descriptions I've used in the PR description field into the code!
@eliykat Yes exactly, this is a transitional class. I'm glad that it becomes apparent when reading the code, means it's not too complex/confusing. As I mention in the Objective part of the PR description:
This PR introduces an temporary bridge between URL filtering and the old state-in-code method. It enables us to move forward with refactoring the table and the navigation, and allow us to work on them separately.
You have a good point, maybe we should add a TD ticket, but really all of this should be removed as part of VVR
There was a problem hiding this comment.
Instead of a TD ticket I added a task to the VVR story instead EC-208 [Admin Console] Add Filters under Left Nav
There was a problem hiding this comment.
Looks good, and serves me right for not reading your PR description properly 🙈
I'll let @jlf0dev mark this thread resolved once he's had a chance to look at it
| node: TreeNode<T>, | ||
| id: string | ||
| ): TreeNode<T> | undefined { | ||
| if (node.node.id === id) { |
There was a problem hiding this comment.
comment: we need to rename the node to object or something at some point 😄
There was a problem hiding this comment.
There's probably some background discussion here that I'm not familiar with, but - object seems worse! Everything's an object! 😅 and Object is a keyword.
There was a problem hiding this comment.
Haha yeah, hopefully we'll get rid of the TreeNode completely and not have to worry about it :D
| import { RoutedVaultFilterModel } from "../shared/models/routed-vault-filter.model"; | ||
|
|
||
| @Injectable() | ||
| export class RoutedVaultFilterService implements OnDestroy { |
There was a problem hiding this comment.
suggestion: a comment here might be helpful as well. The name RoutedVaultFilterService makes sense, but only if you understand why we need it
eliykat
left a comment
There was a problem hiding this comment.
Great PR, 10/10 would review again.
This will also need to be implemented for other clients (particularly desktop) after we've "perfected" it in the web vault. (and by "we" I mean the vault team ;) Can you please create a linked tech debt ticket for that?
|
|
||
| if (filter.type !== undefined && filter.type === "trash") { | ||
| legacyFilter.selectedCipherTypeNode = { | ||
| node: { id: "trash", name: "", icon: "", type: "trash" }, |
There was a problem hiding this comment.
My question was going to be whether we could find the existing Trash node, or export & import the Trash node object, rather than recreating it. It looks like it's currently declared in the VaultFilterComponent though, which I guess we don't really want to pull in to a service.
In any case I agree you should use a real TreeNode object, not really to save any characters, just to be properly typesafe.
apps/web/src/vault/individual-vault/vault-filter/services/routed-vault-filter-bridge.service.ts
Outdated
Show resolved
Hide resolved
| import { RoutedVaultFilterService } from "./routed-vault-filter.service"; | ||
|
|
||
| @Injectable() | ||
| export class RoutedVaultFilterBridgeService { |
There was a problem hiding this comment.
Something I'm wondering about 😁 is it transitional? If so, do we need a tech debt ticket to remove the old services? I assume that when we build the new filter list in the left-hand nav, they'll be routing directly to the query URL rather than going via a service, and then it'll be much simpler to clean up the old code. This feels like something EC pod should do as part of VVR, before handing off to Vault team.
Note that we also have DeprecatedVaultFilterService floating around 🤯
EDIT: ok, after reviewing the rest of the code, (I think) I understand that this is basically a wrapper around existing logic to implement routing with a minimum of code changes. The downside is that it adds complexity in the short term, but I'm OK with this if we're deprecating it quickly after VVR (because the new components won't use it).
| node: TreeNode<T>, | ||
| id: string | ||
| ): TreeNode<T> | undefined { | ||
| if (node.node.id === id) { |
There was a problem hiding this comment.
There's probably some background discussion here that I'm not familiar with, but - object seems worse! Everything's an object! 😅 and Object is a keyword.
apps/web/src/vault/individual-vault/vault-filter/services/routed-vault-filter.service.ts
Outdated
Show resolved
Hide resolved
...eb/src/vault/individual-vault/vault-filter/shared/models/routed-vault-filter-bridge.model.ts
Outdated
Show resolved
Hide resolved
apps/web/src/vault/individual-vault/vault-filter/shared/models/routed-vault-filter.model.ts
Outdated
Show resolved
Hide resolved
|
@eliykat Ticket already seems to exist EC-517 [Tech Debt] Refactor Vault Filter in Browser and Desktop |
apps/web/src/vault/individual-vault/vault-filter/services/routed-vault-filter.service.ts
Outdated
Show resolved
Hide resolved
|
|
||
| if (filter.type !== undefined && filter.type === "trash") { | ||
| legacyFilter.selectedCipherTypeNode = { | ||
| node: { id: "trash", name: "", icon: "", type: "trash" }, |
There was a problem hiding this comment.
lgtm but I'll let @jlf0dev resolve the thread when he's happy
eliykat
left a comment
There was a problem hiding this comment.
I think I've responded to everything above :)
This is needed due to how defaults used to work when using `state-in-code`. We really want to get rid of this type of logic going forward.
...eb/src/vault/individual-vault/vault-filter/shared/models/routed-vault-filter-bridge.model.ts
Outdated
Show resolved
Hide resolved
apps/web/src/vault/individual-vault/vault-filter/services/routed-vault-filter.service.ts
Outdated
Show resolved
Hide resolved
apps/web/src/vault/individual-vault/vault-filter/services/routed-vault-filter.service.ts
Outdated
Show resolved
Hide resolved
apps/web/src/vault/individual-vault/vault-filter/services/routed-vault-filter-bridge.service.ts
Outdated
Show resolved
Hide resolved
It's better that we circle back to this type of navigationt when we're working on the VVR and have more knowledge about how this is supposed to work.
Refactor follows feedback from PR review
…-filters-to-be-routable
eliykat
left a comment
There was a problem hiding this comment.
Great work! Let's get it to QA ![]()
…-filters-to-be-routable
…-filters-to-be-routable
Type of change
Objective
This PR introduces an temporary bridge between URL filtering and the old state-in-code method. It enables us to move forward with refactoring the table and the navigation, and allow us to work on them separately. This is great for smaller PRs and more efficient coding.
Code changes
apps/web/src/vault/individual-vault/vault-filter/components/vault-filter.component.ts: Remove the reverse data flow. I.e. let the data flow one-way into the component. Also remove the
removeInvalidCollectionSelectionfunctionality because it's not needed anymore.apps/web/src/vault/org-vault/vault-filter/vault-filter.component.ts: Same as individual vault component.
apps/web/src/vault/individual-vault/vault-filter/services/abstractions/vault-filter.service.ts: Add ability to get a
cipherTypeTreewhich is needed to be able to populate the bridge filter model with tree nodes.apps/web/src/vault/individual-vault/vault-filter/services/vault-filter.service.ts: Implementation of the above.
apps/web/src/vault/individual-vault/vault-filter/services/routed-vault-filter.service.ts: The new filter service that builds and emits the new filter model based on URL params. Also contains a method for generating routes.
apps/web/src/vault/individual-vault/vault-filter/shared/models/routed-vault-filter.model.ts: The new model used to represent filters. Very basic, only primitives.
apps/web/src/vault/[org and individual]/vault.component.ts: Fetch active filters from the new services. Also remove
applyVaultFilterwhich used direct component references to reload thevault-items.componentapps/web/src/vault/individual-vault/vault-items.component.ts: Reload ciphers when a new
activeFilteris set by the parent component, instead of relying of direct function calls.Temporary compatibility layer
This layer is used to temporary bridge between URL filtering and the old state-in-code method. This should be removed after we have refactored the
vault-items.componentand introduced vertical navigation (which will refactor thevault-filter.component).RoutedVaultFilterServiceand the oldVaultFilterService. When a new filter is emitted the service uses the ids to find the corresponding tree nodes needed for the oldVaultFiltermodel. It then emits a bridge model that contains this information.Screenshots
Nothing has really changed graphically. Works just like usual.
Before you submit